package com.mawendaxiong.blogprovider.blogMain.controller;

import com.mawendaxiong.blogprovider.blogMain.entity.BlogMain;
import com.mawendaxiong.blogprovider.blogMain.service.BlogMainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

@RestController
@RequestMapping("/blogMain/admin")
@Slf4j
public class BlogMainAdminController extends BlogMainController {
    @Autowired
    private BlogMainService service;

    @CrossOrigin
    @PostMapping("addBlog")
    public String addBlog(@RequestBody BlogMain blogMain) {
        blogMain.setKid(UUID.randomUUID().toString().replace("-", ""));
        boolean isSave = service.save(blogMain);
        if (isSave) {
            return "success";
        } else {
            return "fail";
        }
    }

}
